home *** CD-ROM | disk | FTP | other *** search
- '*****************************************************************************
- '
- ' BarMenu1.Bas
- '
- '*****************************************************************************
-
- 'Copyright (c) 1988 Marcel Madonna
-
- 'BARMENU1.BAS shows the use of a simple bar menu
- ' with QBWARE.
- '*****************************************************************************
-
-
- OPTION BASE 1
-
-
- ' Dim arrays for QB Syntax check only - we REDIM them later
-
-
- x% = 1
- DIM Text$(x%), MenuText$(x%), Location%(x%, 2), TColors%(x%, 2), TLength%(x%)
- DIM TblData$(x%), TblSlct%(x%), SText$(x%)
-
-
- ' Set up housekeeping for window drivers
-
- Snow% = 1 'Assume you will see no flicker
- 'Change this value to 0 if the screen
- 'flickers
-
- StackSize% = 20000
- DIM WinStack%(StackSize%) 'Window stack - we keep screen images
- 'and other info here
- DIM WinFrame%(20, 5) 'Define maximum number of windows as 20
- 'we keep specific window data here
- GOSUB A1000.Window.Hskp
-
-
- RESTORE BarMenu.Txt 'Menu items
- GOSUB A0600.BarMenu1 'Go display menu for the 1st time
-
- ON Answer% GOSUB Item1, Item2, Item3, Item4, Item5, Item6
-
-
- GOSUB A1020.PopWindow 'Restore the window used by the menu
- CLS
- PRINT "You have exited without making a selection"
- END
-
- Item1:
- Item2:
- Item3:
- Item4:
- Item5:
- Item6:
-
- GOSUB A1020.PopWindow 'Restore the window used by the menu
- CLS
- PRINT "You have selected item" + STR$(Answer%)
- END
-
-
-
- A0511.LoadText:
-
- READ Count%
- REDIM MenuText$(Count%)
- x% = 1
- READ MenuText$(1)
- WHILE MenuText$(x%) <> "EOM" AND x% <= Count%
- x% = x% + 1
- READ MenuText$(x%)
- WEND
- MenuText$(x%) = ""
- RETURN
-
-
-
- A0600.BarMenu1:
-
- GOSUB A0511.LoadText 'Get menu items into array
-
- ' Determine the widest menu item so we can size the window
-
- LineWidth% = 0
- Height% = 0
- FOR x% = 1 TO UBOUND(MenuText$)
- IF LEN(MenuText$(x%)) > 0 THEN
- Height% = Height% + 1
- IF LEN(MenuText$(x%)) > LineWidth% THEN
- LineWidth% = LEN(MenuText$(x%))
- END IF
- END IF
- NEXT
-
- ' Use Handle 14 and put the window on the screen
- WinHandle% = 14
- Tr% = 5: Lc% = 6: Br% = Tr% + Height% - 1: Rc% = Lc% + LineWidth% + 1
- Fg% = 0: Bg% = 3: Frame% = 2: Shade% = 1
- GOSUB A1010.Prep.Window
-
- A0601.BarMenu1:
- CALL BarMenu1(WinHandle%, WinStack%(), WinFrame%(), WinPoint%, MenuText$(), Answer%)
- RETURN
-
- A1000.Window.Hskp:
-
- Text$ = STRING$(2000, CHR$(176))
- Row% = 1: Col% = 1: Fg% = 0: Bg% = 1
- CALL Putline(Snow%, Text$, Row%, Col%, Fg%, Bg%)
- Text$ = ""
-
- MFg% = 15: MBg% = 0
- MaxWin% = 20
- ExitKeys$ = CHR$(27)
- TabLen% = 8
- SBar% = 1: SRow% = 25: SFg% = 15: Sbg% = 1
-
- CALL InitWin(WinStack%(), WinFrame%(), WinPoint%, MaxWin%, ExitKeys$, TabLen%, SBar%, SRow%, SFg%, Sbg%, Snow%)
- RETURN
-
-
- A1010.Prep.Window:
-
- CALL CngWin(WinHandle%, WinStack%(), Tr%, Lc%, Br%, Rc%, Frame%, Fg%, Bg%, Grow%, Shade%)
-
- CALL PushWin(WinHandle%, WinStack%(), WinFrame%(), WinPoint%)
- CALL Putwind(WinHandle%, WinStack%(), Head$)
- RETURN
-
- A1020.PopWindow:
-
- CALL PopWin(WinStack%(), WinFrame%(), WinPoint%)
- RETURN
-
-
- ' These are the menu choices.
-
- BarMenu.Txt:
- DATA 7
- DATA "A - this is item 1"
- DATA "B - this is item 2"
- DATA "C - this is item 3"
- DATA "D - this is item 4"
- DATA "E - this is item 5"
- DATA "F - this is item 6"
- DATA "EOM"
-
- END
-
-
-